#include <bits/stdc++.h>
#define ll long long
using namespace std;

const int Maxn=1e6+6;
int n,K;
ll a[Maxn],b[Maxn];

inline bool check(ll x){
	int tot=0,p=0;
	for(int i=1;i<=n;i++){
		if(a[i]<=x/2) b[++p]=i;
	}
	ll o=2e9; tot=p;
	for(int j=b[p]+1;j<=n;j++) o=min(o,a[j]);
	for(int j=1;j<b[1];j++) o=min(o,a[j]);
	if(max(a[b[1]],a[b[p]])+o<=x) tot++;
	
	for(int i=1;i<p;i++){
		ll o=2e9;
		for(int j=b[i]+1;j<b[i+1];j++) o=min(o,a[j]);
		if(max(a[b[i]],a[b[i+1]])+o<=x) tot++;
	}
	
	return tot>=K;
}

int main(){
	freopen("sub.in","r",stdin);
	freopen("sub.out","w",stdout);
	
	scanf("%d%d",&n,&K);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	
	ll l=1,r=2e9,ans=0;
	while(l<=r){
		ll mid=(l+r)>>1;
		if(check(mid)) r=mid-1,ans=mid;
		else l=mid+1;
	}
	printf("%lld",ans);

	return 0;
}
/*
5 3
52 62 55 65 33

5 5
56 92 87 7 27

3 3
1000000000 1000000000 1000000000
*/
